***********************************************************************************
******* SOCIAL EXCLUSION AND ETHNIC SEGREGATION IN SCHOOLS: MASTER DO FILE ********
***********************************************************************************

*************************************************
************ TABLES + FIGURES *******************
*************************************************

** Note: This Do File is the master do file that runs all the sub-do files for the paper 
** and creates the tables and figures reported in the paper and online appendix.

******************************
***WORKSPACE AND PATHS********
******************************

	cd "~/Dropbox/Paper/RESTAT/Submission/Replication/Data"
	clear all
	set more off
	version 16.1

	global path1 "./figures"
	global path2 "./tables"

	use "./biat_ethnic.dta", clear

** Packages:

*	ssc install fre; distinct; estout; semipar; coefplot

*****************************
*** MEASURE CONSTRUCTION  ***
*****************************
    
	** Variable Construction and Standardization of outcome var & covariates.
	
	do "./2_variable construction.do"

****************
*** FIGURE 1 ***
****************

	** Figure 1: The Effect of Exposure to Refugees on Teachers’ Ethnic Bias
	
	do "./3.1_figure1.do"

*******************************
*** APPENDIX FIGURE A2 & A3 ***
*******************************

	** Figure A2: Distribution of Teacher’s Ethnic Bias
	** Figure A3: Distribution of Teacher’s Cognitive Ability and Cognitive Empathy
	
	do "./3.2_appendix_figure3.do"

*******************************
*** APPENDIX TABLES A1 & A6 ***
*******************************

	** Table A1: Student Ability Sorting Across Classrooms - Supplemented Sample
	** Table A6: Social Ties in Classrooms with no Refugees 
	
	do "./4.1_appendix_tables_supplemented sample.do"

********************************************
*** DESCRIPTIVE TABLES AND BALANCE CHECK ***
********************************************

	** Table 1: Refugee and Host Student Characteristics
	** Table 2: Teacher and Classroom Characteristics
	** Table 3: Balance Test: Teachers’ Ethnic Bias and Pre-Determined Student Characteristics
	** Table 4: What Predicts Teacher’s Ethnic Bias?
	
	do "./4.2_descriptive analysis.do"

**************************
*** APPENDIX TABLES A2 ***
**************************

	** Table A2: Allocation of Refugee Students Across Teachers
	
	do "./4.3_analysis_appendix table 2.do"

*******************
*** MAIN TABLES ***
*******************

	** Table 5: Teachers’ Ethnic Bias and Social Exclusion
	** Table 6: Teacher’s Ethnic Bias and Inter-Ethnic Ties
	** Table 7: Teachers’ Ethnic Bias on Bullying and Student Achievement
	
	do "./4.4_analysis_main tables.do"

********************************
*** APPENDIX FIGURES A4 & A5 ***
********************************

	** Figure A4: Teachers’ Ethnic Bias and Excess Host and Refugee Homophily
	** Figure A5: Teachers’ Implicit Bias and Their Assessment of Students’ Behavioral Conduct
	
	do "./4.5_appendix_figures.do"

****************
*** FIGURE 2 ***
****************

	** Figure 2: Potential Mechanisms
	
	do "./4.6_figure 2.do"

************************************
*** APPENDIX TABLES A3 & A4 & A5 ***
************************************

	** Table A3: Truncated Regression - Inter-Ethnic Ties
	** Table A4: Robustness Check - Model with No Teacher Controls
	** Table A5: Robustness Check - Model with Classroom FE
	
	do "./5_robustness.do"

	dis "Do File Complete"

	
